<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>正则表达式中的y模式</title>
</head>
<body>
    <script>
        let hd = "uhuhunskfg";

        // g模式匹配的时候，如果不是要匹配的内容，就会直接忽略，匹配下一个
        let reg = /u/g;
        console.log(reg.exec(hd));
        console.log(reg.exec(hd));

        // y模式匹配的时候，如果不是要匹配的内容，不会忽略，直接停止,并返回到最开始的位置
        let reg1 = /u/y;
        console.log(reg1.exec(hd));
        console.log(reg1.exec(hd));


        let hdms = `后盾人的qq是7777777,88888888,9999999欢迎拨打`;
        let reg2 = /(\d+),?/y;
        reg2.lastIndex = 7;
        let qq = [];
        while(res = reg2.exec(hdms)){
            qq.push(res[1]);
        }
        console.log(qq);
    </script>
</body>
</html>